<template>
  <div class="app-container report">
    <div class="con">
      <el-form inline>
        <el-row :gutter="10" class="mb8">
          <el-col :span="24">
            <el-form-item label="检验日期:">
              <Date-picker
                type="date"
                placeholder="选择日期"
                style="width: 120px"
                v-model="queryParams.xjtDateBegin"
                @on-change="get_date($event, 's')"
              ></Date-picker>
              —
              <Date-picker
                type="date"
                placeholder="选择日期"
                style="width: 120px"
                v-model="queryParams.xjtDateEnd"
                @on-change="get_date($event, 'e')"
              ></Date-picker>
            </el-form-item>
            <el-form-item label="机台编号:">
              <el-select filterable clearable v-model="queryParams.xjtJtbh">
                <el-option
                  v-for="item in listJtmJtbh"
                  :key="item"
                  :label="item"
                  :value="item"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="客户编码:">
              <HdSelectMaterial
                v-model="queryParams.xjtCustwldm"
                keyName="itmCustwldm"
              />
            </el-form-item>
            <el-form-item>
              <Button type="info" style="display: inline-block" @click="getList"
                >查询</Button
              >
            </el-form-item>
            <el-form-item>
              <Button
                type="info"
                style="display: inline-block"
                :loading="exportLoading"
                @click="handleExport"
                >导出</Button
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>

    <div style="position: relative">
      <div style="position: absolute; right: 0; top: -30px">
        <Page
          :total="total"
          :current.sync="queryParams.pageNum"
          simple
          :page-size="queryParams.pageSize"
          show-elevator
          @on-change="pageChange"
        ></Page>
      </div>
      <el-table
        id="NoPlanAssign"
        border
        stripe
        highlight-current-row
        :data="xjtData"
        :header-cell-style="{ 'text-align': 'center' }"
      >
        <el-table-column label="#" width="40" type="index" align="center" />
        <el-table-column
          label="机台编号"
          :show-overflow-tooltip="true"
          width="150"
          align="center"
          prop="xjtJtbh"
        />
        <el-table-column
          label="检验日期"
          :show-overflow-tooltip="true"
          width="100"
          align="center"
          prop="xjtJyrq"
        />
        <el-table-column
          label="班次代码"
          :show-overflow-tooltip="true"
          width="100"
          align="center"
          prop="xjtBbdm"
        />
        <!--        <el-table-column label="巡检时段" :show-overflow-tooltip="true" width="100" align="center" prop="xjtXjrq"/>-->
        <el-table-column
          label="客户编码"
          :show-overflow-tooltip="true"
          width="150"
          align="center"
          prop="xjtCustwldm"
        />
        <el-table-column
          label="物料品名"
          :show-overflow-tooltip="true"
          width="250"
          align="center"
          prop="xjtWlpm"
        />
        <el-table-column
          label="操作"
          align="center"
          width="100"
          class-name="small-padding fixed-width"
        >
          <template #default="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 查询 -->
    <Modal
      v-model="check_search"
      draggable
      scrollable
      title="查询"
      width="570"
      @on-ok="getList"
    >
      <div style="text-align: center">
        <Form inline>
          <FormItem label="检验日期" style="width: 90%">
            <Date-picker
              type="date"
              placeholder="选择日期"
              style="width: 40%"
              v-model="queryParams.xjtDateBegin"
              @on-change="get_date($event, 's')"
            ></Date-picker>
            >>>
            <Date-picker
              type="date"
              placeholder="选择日期"
              style="width: 40%"
              v-model="queryParams.xjtDateEnd"
              @on-change="get_date($event, 'e')"
            ></Date-picker>
          </FormItem>
          <br />
        </Form>
      </div>
    </Modal>

    <el-dialog v-model="open" fullscreen width="100%" class="myDialog">
      <div style="text-align: center; border-bottom: none">
        <div style="width: 100%; position: relative">
          <h1 style="font-weight: bold">空调面板巡检记录表</h1>
          <div class="xjOrder">HD/JL ZLB-011</div>
        </div>
      </div>
      <div v-if="open">
        <table style="height: 500px; font-size: 14px">
          <tr>
            <td>机台</td>
            <td>{{ xjtDataObj.xjtJtbh }}</td>
            <td>物料名称</td>
            <td colspan="3">{{ xjtDataObj.xjtWlpm }}</td>
            <td>物料编码</td>
            <td colspan="3">{{ xjtDataObj.xjtCustwldm }}</td>
            <td>检查日期</td>
            <td colspan="2">{{ xjtDataObj.xjtJyrq }}</td>
            <td>班别</td>
            <td colspan="2">{{ xjtDataObj.xjtBbdm }}</td>
          </tr>
          <tr>
            <td rowspan="2">
              检查
              <br />
              时间
              <br />
              2H/1模
            </td>
            <td>外观</td>
            <td>关键尺寸面板铰链距离长度</td>
            <td>颜色(不允许偏黄)</td>
            <td>光泽度</td>
            <td>重量</td>
            <td colspan="3">(TCL)显示效果</td>
            <td>透光</td>
            <td>(海尔)色母机</td>
            <td colspan="2">整机装配</td>
            <td rowspan="2">判定</td>
            <td rowspan="2">检查员</td>
            <td rowspan="2" style="width: 10%">备注</td>
          </tr>
          <tr>
            <td>表面不得有披锋毛刺、缺口、缩水等</td>
            <td>
              <div v-if="xjtDataObj.xjtJccc1X">
                {{ parseFloat(xjtDataObj.xjtJccc1X).toFixed(2) }}~{{
                  parseFloat(xjtDataObj.xjtJccc1S).toFixed(2)
                }}
              </div>
            </td>
            <td>{{ xjtDataObj.xjtStandardColor }}</td>
            <td>&emsp;</td>
            <td>
              <div v-if="xjtDataObj.xjtJzX">
                {{ parseFloat(xjtDataObj.xjtJzX).toFixed(1) }}~
                <br />
                {{ parseFloat(xjtDataObj.xjtJzS).toFixed(1) }}
              </div>
            </td>
            <td>显示窗透光OK</td>
            <td>显示窗厚度1.30-1.45</td>
            <td>显示区无明显塌陷及鼓包，对照封样件</td>
            <td>
              海尔按照6%--8%进行控制。
              <br />
              TCL按照2%--8%进行控制。
            </td>
            <td>检查显隐面板色母机是否调整</td>
            <td>面板与中框互配时的间隙均匀,面板与中框装配后间隙小于3.0</td>
            <td>
              开合时，面板铰链与中框不允许出现干涉，面板打开后不允许存在铰链挂不住现象
            </td>
          </tr>
          <tr>
            <td>H1</td>
            <!--            外观-->
            <td>
              <div>{{ xjtDataObj2.xjtViewTen }}</div>
            </td>
            <!--            尺寸-->
            <td>
              <div>{{ xjtDataObj2.xjtSizeoneCavoneTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtColourTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtLustre1 }}</div>
            </td>
            <!--            变形量-->
            <td>
              <div>{{ xjtDataObj2.xjtWeightoneCavoneTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtShowPenetrationTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtWindowThicknessTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtCollapseTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtControlTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtAdjustmentTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtGapTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtInterfereTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJudgementTen }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJyryTenName }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtDescTen }}</div>
            </td>
          </tr>
          <tr>
            <td>H2</td>
            <!--            外观-->
            <td>
              <div>{{ xjtDataObj2.xjtViewZero }}</div>
            </td>
            <!--            尺寸-->
            <td>
              <div>{{ xjtDataObj2.xjtSizeoneCavoneZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtColourZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtLustre2 }}</div>
            </td>
            <!--            变形量-->
            <td>
              <div>{{ xjtDataObj2.xjtWeightoneCavoneZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtShowPenetrationZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtWindowThicknessZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtCollapseZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtControlZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtAdjustmentZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtGapZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtInterfereZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJudgementZero }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJyryZeroName }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtDescZero }}</div>
            </td>
          </tr>
          <tr>
            <td>H3</td>
            <!--            外观-->
            <td>
              <div>{{ xjtDataObj2.xjtViewTwo }}</div>
            </td>
            <!--            尺寸-->
            <td>
              <div>{{ xjtDataObj2.xjtSizeoneCavoneTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtColourTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtLustre3 }}</div>
            </td>
            <!--            变形量-->
            <td>
              <div>{{ xjtDataObj2.xjtWeightoneCavoneTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtShowPenetrationTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtWindowThicknessTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtCollapseTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtControlTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtAdjustmentTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtGapTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtInterfereTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJudgementTwo }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJyryTwoName }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtDescTwo }}</div>
            </td>
          </tr>
          <tr>
            <td>H4</td>
            <!--            外观-->
            <td>
              <div>{{ xjtDataObj2.xjtViewFour }}</div>
            </td>
            <!--            尺寸-->
            <td>
              <div>{{ xjtDataObj2.xjtSizeoneCavoneFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtColourFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtLustre4 }}</div>
            </td>
            <!--            变形量-->
            <td>
              <div>{{ xjtDataObj2.xjtWeightoneCavoneFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtShowPenetrationFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtWindowThicknessFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtCollapseFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtControlFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtAdjustmentFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtGapFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtInterfereFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJudgementFour }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJyryFourName }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtDescFour }}</div>
            </td>
          </tr>
          <tr>
            <td>H5</td>
            <!--            外观-->
            <td>
              <div>{{ xjtDataObj2.xjtViewSix }}</div>
            </td>
            <!--            尺寸-->
            <td>
              <div>{{ xjtDataObj2.xjtSizeoneCavoneSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtColourSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtLustre5 }}</div>
            </td>
            <!--            变形量-->
            <td>
              <div>{{ xjtDataObj2.xjtWeightoneCavoneSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtShowPenetrationSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtWindowThicknessSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtCollapseSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtControlSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtAdjustmentSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtGapSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtInterfereSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJudgementSix }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtJyrySixName }}</div>
            </td>
            <td>
              <div>{{ xjtDataObj2.xjtDescSix }}</div>
            </td>
          </tr>

          <tr>
            <td style="text-align: left" colspan="18">
              说明：①关键尺寸按图纸或检验文件规定；②测量颜色时应于不同位置测三次以上，以客户提供的样板或色板为测量标准；
              ③尺寸、颜色、重量等测量周期按相关检验文件规定；④包装方式按控制计划与SOP执行；⑤检测项目符合时在判定栏注明“OK”，不符合时注明“NG”，并简要注明不良内容，班首件检验时应注明“班首件”；⑤测试数据不够栏填写可以另起页填写。
            </td>
          </tr>
        </table>
        <div style="display: block; text-align: right; margin-top: 10px">
          <el-button type="primary" size="mini" @click="open = false"
            >退出</el-button
          >
        </div>
      </div>
      <div slot="footer"></div>
    </el-dialog>
  </div>
</template>

<script>
import { parseTime } from "@/utils/ruoyi";
import {
  listPanelDedicatedTemplateById,
  listXjtDataForReport,
  savePanelDedicatedTemplate,
  exportTable,
} from "@/api/quality/productBom";
import mixins from "@/mixins/common";
export default {
  name: "ProductBomDedicatedReport",
  mixins: [mixins.listJtmJtbh],
  data() {
    return {
      //外部数据表格
      xjtData: [],
      exportLoading: false,
      xjtData2: [],
      xjtDataObj: [],
      xjtDataObj2: [],
      xjtDataRow: [],
      tableData: [],
      tableData2: [],
      cityList: [
        {
          value: "OK",
          label: "OK",
        },
        {
          value: "NG",
          label: "NG",
        },
      ],
      value3: " ",
      title: "",
      open: false,
      dom1: null,
      dom2: null,
      //当前时间
      nowTime: "",
      check_search: false,
      tt_s: new Date(new Date().getTime() - 86400 * 30000),
      tt_e: new Date(new Date().getTime() + 86400 * 60000),
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: document.body.clientHeight > 900 ? 25 : 17,
        xjtType: "B",
        xjtDateBegin: this.getTime(new Date().getTime() - 86400 * 30000).slice(
          0,
          10
        ),
        xjtDateEnd: this.getTime(new Date().getTime() + 86400 * 60000).slice(
          0,
          10
        ),
      },
      timeDay: null,
      hTime: {
        H1: "H1",
        H2: "H2",
        H3: "H3",
        H4: "H4",
        H5: "H5",
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    listenerScroll() {
      this.dom2.addEventListener("scroll", () => {
        // 横滚
        this.dom1.scrollLeft = this.dom2.scrollLeft;
      });
    },

    getList() {
      this.queryParams.xjtDateBegin = this.moment(
        this.queryParams.xjtDateBegin
      ).format("YYYY-MM-DD");
      this.queryParams.xjtDateEnd = this.moment(
        this.queryParams.xjtDateEnd
      ).format("YYYY-MM-DD");

      listXjtDataForReport(this.queryParams).then((res) => {
        this.xjtData = res.rows;
        this.total = res.total;
      });
    },
    handleUpdate(row) {
      this.xjtDataRow = row;
      this.timeDay = row.timeDay;
      //当前时间段
      this.nowTime = row.timeDay;
      this.open = true;
      //请求数据,按照机台编号,
      listPanelDedicatedTemplateById(row.xjtId).then((res) => {
        let xjtData1 = res.data.list1;
        let xjtData2 = res.data.list2.map((o) => {
          if (o.xjtInformation) {
            let obj = JSON.parse(o.xjtInformation);
            o = Object.assign(o, obj);
          }
          return o;
        });
        xjtData1.map((item) => {
          this.xjtDataObj = item;
        });
        xjtData2.map((ite) => {
          this.xjtDataObj2 = ite;
        });
      });
    },
    handleRow() {
      switch (this.timeDay) {
        case "H1":
          this.xjtDataObj2.xjtAnalyzeTen = this.getTime();
          this.xjtDataObj2.xjtFlagTen = "1";
          this.xjtDataObj2.xjtJyryTen = this.$store.getters.name;
          break;
        case "H2":
          this.xjtDataObj2.xjtAnalyzeZero = this.getTime();
          this.xjtDataObj2.xjtFlagZero = "1";
          this.xjtDataObj2.xjtJyryZero = this.$store.getters.name;
          break;
        case "H3":
          this.xjtDataObj2.xjtAnalyzeTwo = this.getTime();
          this.xjtDataObj2.xjtFlagTwo = "1";
          this.xjtDataObj2.xjtJyryTwo = this.$store.getters.name;
          break;
        case "H4":
          this.xjtDataObj2.xjtAnalyzeFour = this.getTime();
          this.xjtDataObj2.xjtFlagFour = "1";
          this.xjtDataObj2.xjtJyryFour = this.$store.getters.name;
          break;
        case "H5":
          this.xjtDataObj2.xjtAnalyzeSix = this.getTime();
          this.xjtDataObj2.xjtFlagSix = "1";
          this.xjtDataObj2.xjtJyrySix = this.$store.getters.name;
          break;
      }
      savePanelDedicatedTemplate(this.xjtDataObj2).then((res) => {
        this.open = false;
        this.$message.success("保存成功！");
        this.getList();
      });
    },
    cancel() {
      this.open = false;
    },
    get_date(e, type) {
      if (type === "s") {
        this.queryParams.xjtDateBegin = e;
      } else if (type === "e") {
        this.queryParams.xjtDateEnd = e;
      }
    },
    getTime(time = new Date()) {
      return parseTime(time);
    },
    pageChange(page) {
      this.queryParams.pageNum = page;
      this.getList();
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.exportLoading = true;
      return exportTable(queryParams).then((response) => {
        this.download(response.msg);
        this.exportLoading = false;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.report {
  input {
    width: 60px;
  }

  table {
    width: 100%;
    height: 50px;
    border-spacing: 0;
    border-collapse: collapse;
    text-align: center;
    font-weight: bold;
  }

  table td {
    height: 40px;
    width: 82px;
    border: 1px solid black;
  }

  .xjTable {
    width: 100%;
    text-align: center;
    font-size: 24px;
    height: 48px;
    font-weight: bold;
  }

  .hdLogo {
    position: absolute;
    left: 34px;
    bottom: 8px;
    width: 130px;
    height: 58px;
  }

  .xjOrder {
    position: absolute;
    right: 70px;
    bottom: 2px;
    font-weight: bold;
    font-size: 16px;
  }

  .myDialog {
    ::v-deep .el-table thead th {
      height: 30px;
      font-size: 12px;
      padding: 0px 0px 0px 0px;
      color: #47494e;
      background: #f8f8f8 !important;
    }
    ::v-deep .el-table td .cell {
      height: 100%;
    }
    ::v-deep .el-select .el-input .el-input__suffix .el-input__suffix-inner {
      display: none;
    }

    ::v-deep .el-table__body-wrapper .el-select .el-input .el-input__inner {
      text-align: center;
    }
    /*z*/
    ::v-deep .el-input__inner {
      padding: 0;
      height: 23px;
      line-height: 23px;
      color: #000;
    }
    ::v-deep .inputWidth {
      width: 50px;
    }

    ::v-deep .divHeight {
      border-bottom: 1px solid #868686;
      height: 20px;
    }
    ::v-deep .demoColor input {
      background: #ffb3a7 !important;
    }
  }
}
</style>
